package com.blog.wu.myblog.shiro;

import org.apache.shiro.authc.credential.PasswordService;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.stereotype.Service;

/**
 * @Author wuyanshen
 * @Date 2018-11-03 10:58 PM
 * @Discription 描述
 */
@Service
public class PasswordServiceImpl implements PasswordService {

    private String algorithmName = "md5";//算法名称 md5
    private int iterations = 3;//散列次数 3->散列3次

    //对密码加密
    @Override
    public String encryptPassword(Object o) throws IllegalArgumentException {
        PasswordVO passwordVO = (PasswordVO) o;
        return new SimpleHash(algorithmName, passwordVO.getPassword(), passwordVO.getSalt(), iterations).toBase64();
    }

    @Override
    public boolean passwordsMatch(Object o, String s) {
        return false;
    }
}
